package com.xquant.trade.trade.controller;

import com.xquant.trade.trade.service.SettleService;
import com.xquant.trade.utils.CommResponse;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("settle")
public class SettleController {

    @Autowired
    private SettleService settleService;

    @RequestMapping(value = "/settleDays.action")
    public CommResponse settleDays(@RequestParam Map param) {
        String begDate = MapUtils.getString(param, "begDate");
        String endDate = MapUtils.getString(param, "endDate");
        try {
            CommResponse response = settleService.settleDays(begDate, endDate);
            return response;
        } catch (Exception ex) {
            return CommResponse.failure(ex.toString());
        }
    }

    @RequestMapping(value = "/getSettleInfo.action")
    public CommResponse getSettleInfo() {
        Map ret = settleService.getSettleInfo();
        return CommResponse.success(ret);
    }

    @RequestMapping(value = "/getBlcDate.action")
    public CommResponse getBlcDate() {
        String ret = settleService.getBlcDate();
        return CommResponse.success(ret);
    }
}
